home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_06_07 / v6n7070a.txt < prev    next >
Text File  |  1989-09-26  |  2KB  |  77 lines

  1. /* PRN device driver which truncates lines and paginates */
  2.  
  3. #define  LINES_PER_PAGE  55
  4. #define  LINE_LENGTH     79
  5. #define  TAB_SPACING      8
  6.  
  7. #include "dd.h"
  8. #include <dos.h>
  9.  
  10. void init() {
  11. request_header->status = DONE_STATUS;
  12. }
  13.  
  14. void media_check() {bad_device_driver_function();}
  15. void build_bpb() {bad_device_driver_function();}
  16. void ioctl_input() {bad_device_driver_function();}
  17. void input() {bad_device_driver_function();}
  18. void nondestructive_input() {bad_device_driver_function();}
  19. void input_status() {bad_device_driver_function();}
  20. void input_flush() {bad_device_driver_function();}
  21.  
  22. static void BIOS_print(c) int c; {
  23. union REGS r;
  24. r.h.ah = 0;
  25. r.h.al = c;
  26. r.x.dx = 0;
  27. int86(0x17, &r, &r);
  28. if (r.h.ah&1) {
  29.   request_header->status = ERROR_STATUS+DONE_STATUS+WRITE_FAULT;
  30.   exit();
  31.   }
  32. }
  33.  
  34. static int line = 0;
  35. static int column = 0;
  36.  
  37. static void print_character(c) int c; {
  38. switch (c) {
  39.   case '\t':
  40.     do print_character(' ');
  41.     while (column%TAB_SPACING!=0 && column<LINE_LENGTH);
  42.     break;
  43.   case '\f':
  44.     BIOS_print(c);
  45.     line = 0;
  46.     break;
  47.   case '\r':
  48.     BIOS_print(c);
  49.     column = 0;
  50.     break;
  51.   case '\n':
  52.     BIOS_print(c);
  53.     if (++line == LINES_PER_PAGE) {
  54.       BIOS_print('\f');
  55.       line = 0;
  56.       }
  57.     break;
  58.   default:
  59.     if (' '<=c && c<='~' && column<LINE_LENGTH) {
  60.       BIOS_print(c);
  61.       column++;
  62.       }
  63.   }
  64. }
  65.  
  66. void output() {
  67. int k;
  68. for (k=0; k<request_header->x.io.count; k++)
  69.   print_character(request_header->x.io.transfer_address[k]);
  70. request_header->status = DONE_STATUS;
  71. }
  72.  
  73. void output_with_verify() {bad_device_driver_function();}
  74. void output_status() {bad_device_driver_function();}
  75. void output_flush() {bad_device_driver_function();}
  76. void ioctl_output() {bad_device_driver_function();}
  77.